package com.zlq.cn.util.des.hash;


public class HrConverter {

	/**
	 * To bcd.
	 * 
	 * @param src
	 *            the src
	 * @return the string
	 * @throws Exception
	 *             输入参数不合法.
	 */
	public static String bytesToBCD(byte[] src) throws Exception {
		return HrBCD.encode(src);
	}

	/**
	 * BCD to bytes.
	 * 
	 * @param src
	 *            the src
	 * @return the byte[]
	 * @throws Exception
	 *             输入参数不合法.
	 */
	public static byte[] BCDToBytes(String src) throws Exception {
		return HrBCD.decode(src);
	}

	/**
	 * To base64.
	 * 
	 * @param src
	 *            the src
	 * @return the string
	 * @throws Exception
	 *             输入参数不合法.
	 */
	public static String bytesToBase64(byte[] src) throws Exception {
		return new String(HrBase64.encode(src));
	}

	/**
	 * Base64 to bytes.
	 * 
	 * @param src
	 *            the src
	 * @return the byte[]
	 * @throws Exception
	 *             输入参数不合法.
	 */
	public static byte[] base64ToBytes(String src) throws Exception {
		return HrBase64.decode(src.getBytes());
	}

	/**
	 * To hex.
	 * 
	 * @param src
	 *            the src
	 * @return the string
	 * @throws Exception
	 *             输入参数不合法.
	 */
	public static String bytesToHex(byte[] src) throws Exception {
		return HrHex.encode(src);
	}

	/**
	 * Hex to bytes.
	 * 
	 * @param src
	 *            the src
	 * @return the byte[]
	 * @throws Exception
	 *             输入参数不合法.
	 */
	public static byte[] hexToBytes(String src) throws Exception {
		return HrHex.decode(src);
	}
}
